#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


Program 1.5.1 - Generating a random sequence

Syntax:
python randomseq.py 1000


Notes:
int(sys.argv[1]) == Integer.parseInt(args[0])

sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

random is a required import as a substitute for Java's Math.random()
https://docs.python.org/2/library/random.html

'''

import sys
import random


def main():
    ''' Generate a user-defined random sequence of numbers '''

    try:
        numbers = int(sys.argv[1])
    except IndexError:
        print 'Integer for numbers to generate is required.'
        print 'Syntax: "python randomseq.py 10"'
        sys.exit(0)

    for _ in range(numbers):
        print random.random()


if __name__ == '__main__':
    main()
